<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>state </title>
</head>

<body>
    <div id="app" ></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <!-- 专门设置props的库 -->
    <script src="../js/prop-types.js"></script>
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
        class MyData extends React.Component {
            constructor(props) {
                super(props)
                this.chg =this.chg.bind(this)
                this.state={
                    msg:'我是信息'
                }
            }
            chg(num){
                console.log(this.state.msg)                
                console.log(num)
            }
                // 加上() 就代表自己去执行这个方法了
                // 先写匿名函数,在函数里边去传值,也相当于,回调的事
            render() {
                return  <div onClick={ ()=>{ return this.chg(2) } } >事件源对象 </div>                 
            }
        }
        ReactDOM.render(<MyData />, document.getElementById('app'))
    </script>
</body>

</html>